An adaptive grammar is a formal grammar that explicitly provides mechanisms within the formalism to allow its own production rules to be manipulated.
John N. Shutt defines adaptive grammars as follows:
Types of manipulation include rule addition, deletion, and modification.
The first description of grammar adaptivity (though not under that name) in the literature is generally[2][3][4] taken to be in a paper by Alfonso Caracciolo di Forino published in 1963.[5] The next generally accepted reference to an adaptive formalism (extensible context-free grammars) came from Wegbreit in 1970[6] in the study of extensible programming languages, followed by the dynamic syntax of Hanford and Jones in 1973.[7]
Until fairly recently, much of the research into the formal properties of adaptive grammars was uncoordinated between researchers, only first being summarized by Henning Christiansen in 1990[2] in response to a paper in ACM SIGPLAN Notices by Boris Burshteyn.[8] The Department of Engineering at the University of São Paulo has its Adaptive Languages and Techniques Laboratory, specifically focusing on research and practice in adaptive technologies and theory. The LTA also maintains a page naming researchers in the field.[9]
While early efforts made reference to dynamic syntax[7] and extensible,[6] modifiable,[10] dynamic,[11] and adaptable[2][12] grammars, more recent usage has tended towards the use of the term adaptive (or some variant such as adaptativa,[13][14] depending on the publication language of the literature).[3] Iwai refers to her formalism as adaptive grammars,[13] but this specific use of simply adaptive grammars is not typically currently used in the literature without name qualification. Moreover, no standardization or categorization efforts have been undertaken between various researchers, although several have made efforts in this direction.[3][4]
Shutt categorizes adaptive grammar models into two main categories:[3][15]
Jackson refines Shutt's taxonomy, referring to changes over time as global and changes over space as local, and adding a hybrid time-space category:[4]
Adaptive formalisms may be divided into two main categories: full grammar formalisms (adaptive grammars), and adaptive machines, upon which some grammar formalisms have been based.
The following is a list (by no means complete) of grammar formalisms that, by Shutt's definition above, are considered to be (or have been classified by their own inventors as being) adaptive grammars. They are listed in their historical order of first mention in the literature.
Described in Wegbreit's doctoral dissertation in 1970,[6] an extensible context-free grammar consists of a context-free grammar whose rule set is modified according to instructions output by a finite state transducer when reading the terminal prefix during a leftmost derivation. Thus, the rule set varies over position in the generated string, but this variation ignores the hierarchical structure of the syntax tree. Extensible context-free grammars were classified by Shutt as imperative.[3]
First introduced in 1985 as Generative Grammars[16] and later more elaborated upon,[17] Christiansen grammars[18] are an adaptive extension of attribute grammars. Christiansen grammars were classified by Shutt as declarative.[3]
The redoubling language is demonstrated as follows:[17]
<program↓G> → <dcl↓G↑w> <body↓{w-rule}>
where w-rule = <body↓G’> → w
<dcl↓G↑ch•w> → <char↓G↑ch> <dcl↓G↑w> <dcl↓G↑<>> → <ε> <char↓G↑a> → a
First introduced in May 1990[8] and later expanded upon in December 1990,[10] modifiable grammars explicitly provide a mechanism for the addition and deletion of rules during a parse. In response to the ACM SIGPLAN Notices responses, Burshteyn later modified his formalism and introduced his adaptive Universal Syntax and Semantics Analyzer (USSA) in 1992.[19] These formalisms were classified by Shutt as imperative.[3]
Introduced in 1993, Recursive Adaptive Grammars (RAGs) were an attempt to introduce a Turing powerful formalism that maintained much of the elegance of context-free grammars.[3] Shutt self-classifies RAGs as being a declarative formalism.
Boullier's dynamic grammars, introduced in 1994,[11] appear to be the first adaptive grammar family of grammars to rigorously introduce the notion of a time continuum of a parse as part of the notation of the grammar formalism itself.[4] Dynamic grammars are a sequence of grammars, with each grammar Gi differing in some way from other grammars in the sequence, over time. Boullier's main paper on dynamic grammars also defines a dynamic parser, the machine that effects a parse against these grammars, and shows examples of how his formalism can handle such things as type checking, extensible languages, polymorphism, and other constructs typically considered to be in the semantic domain of programming language translation.
The work of Iwai in 2000[13] takes the adaptive automata of Neto[20] further by applying adaptive automata to context-sensitive grammars. Iwai's adaptive grammars (note the qualifier by name) allow for three operations during a parse: ? query (similar in some respects to a syntactic predicate, but tied to inspection of rules from which modifications are chosen), + addition, and - deletion (which it shares with its predecessor adaptive automata).
Introduced in 2000[21] and most fully discussed in 2006,[4] the §-Calculus (§ here pronounced meta-ess) allows for the explicit addition, deletion, and modification of productions within a grammar, as well as providing for syntactic predicates. This formalism is self-classified by its creator as both imperative and adaptive, or, more specifically, as a time-space adaptive grammar formalism, and was further classified by others as being an analytic formalism.[14][22]
The redoubling language is demonstrated as follows:
grammar ww { S ::= #phi(A.X<-"") R; R ::= $C('[ab]') #phi(A.X<-A.X C) #phi(N<=A.X) N | R; };
(Note on notation: In the above example, the #phi(...) statements identify the points in the production R that modify the grammar explicitly. #phi(A.X<-A.X C) represents a global modification (over time) and the #phi(N<=A.X) statement identifies a local modification (over space). The #phi(A.X<-"") statement in the S production effectively declares a global production called A.X by placing the empty string into that production before its reference by R.)
First described by Neto in 2001,[23] adaptive devices were later enhanced and expanded upon by Pistori in 2003.[24]
In 2002,[25] Adam Carmi introduced an LALR(1)-based adaptive grammar formalism known as Adapser. Specifics of the formalism do not appear to have been released.
In 2004,[14] César Bravo introduced the notion of merging the concept of appearance checking[26] with adaptive context-free grammars, a restricted form of Iwai's adaptive grammars,[13] showing these new grammars, called Adaptive CFGs with Appearance Checking to be Turing powerful.
The formalisms listed below, while not grammar formalisms, either serve as the basis of full grammar formalisms, or are included here because they are adaptive in nature. They are listed in their historical order of first mention in the literature.